﻿using System;
using System.Collections.Generic;
using System.Globalization;
using Monkey.Warrenty.Data;
using Monkey.Warrenty.Data.Interfaces;
using Monkey.Warrenty.EntityModel;

namespace Monkey.Warrenty.Biz
{
    public class ReportingBiz
    {
        private static IReportingDao _reportingDao;

        private static IReportingDao ReportingData
        {
            get { return _reportingDao ?? (_reportingDao = new ReportingDao()); }
        }

        public static List<ReportEmployeeInstantTicket_Result> ReportEmployeeInstantTicket(string dateFrom, string dateTo, string dateFormat)
        {
            DateTime? dtFrom = null, dtTo = null;
            DateTime date1, date2;

            if (DateTime.TryParseExact(dateFrom, dateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None,
                out date1))
            {
                dtFrom = date1;
            }

            if (DateTime.TryParseExact(dateTo, dateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None,
                out date2))
            {
                dtTo = date2.AddDays(1);
            }

            return ReportingData.ReportEmployeeInstantTicket(dtFrom, dtTo);
        } 
    }
}
